package leetcode.median;

import leetcode.base.ListNode;

/**
 * ClassName: $24_SwapPairs
 * Description:
 * date: 2022-02-19 21:08
 *
 * @author liyifan
 */
public class $24_SwapPairs {
    public ListNode swapPairs(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }

        ListNode next = head.next;
        ListNode nexNext = next.next;
        next.next = head;
        head.next = swapPairs(nexNext);

        return next;
    }
}
